home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
17 Bit Software 6: Level 6
/
17 Bit - Level 6 (1998)(Epic Marketing)[!].iso
/
!applications!
/
crmv1.91t
/
developer
/
assembler
/
examples
/
crmpw.s
< prev
Wrap
Text File
|
1993-02-03
|
4KB
|
194 lines
***********************************
*** CrMPW V1.0 ***
*** (c) 1993 Thomas Schwarz ***
***********************************
incdir dh0:ass/Include/
include dos/dos_lib.i
include exec/exec_lib.i
include utility/tagitem.i
include libraries/CrM.i
include libraries/CrM_lib.i
***************************************
CALL MACRO
jsr _LVO\1(a6)
ENDM
CALLEXEC MACRO
move.l 4.w,a6
CALL \1
ENDM
CALLDOS MACRO
move.l _DOSBase(pc),a6
CALL \1
ENDM
***************************************
main:
lea CLIParas(pc),a1
movem.l d0/a0,(a1) ;save CLI-Parameters
** Open dos.library: **
lea DOSName(pc),a1
CALLEXEC OldOpenLibrary
lea _DOSBase(pc),a0
move.l d0,(a0)
beq.w .End
** Get Output Handle for the CLI: **
move.l d0,a6
CALL Output
lea OutHandle(pc),a0
move.l d0,(a0)
beq.w .CloseDOS
** Open CrM.library: **
lea CrMName(pc),a1
moveq #4,d0
CALLEXEC OpenLibrary
lea _CrMBase(pc),a0
move.l d0,(a0)
beq.w .nocrm
lea InitTxt(pc),a0
bsr.w PrintText
movem.l CLIParas(pc),d0/a0
tst.l d0
beq.w .printinfo
clr.b -1(a0,d0.w) ;replace <cr> with 0
bsr.w SkipSpaces
move.b (a0),d1
beq.w .printinfo ;no parameters
bclr #5,d1 ;upcase
cmp.b #"A",d1
beq.s .checkadd ;check for following <Space>
cmp.b #"R",d1
beq.s .checkremove ;check for following <Space>
.switch:
moveq #0,d0
.checkcont:
; lea PW(pc),a1
; move.l a0,(a1) ;store address of pw
tst.b (a0)
beq.w .nopw ;TextEnd!
move.l d0,d7
move.l _CrMBase(pc),a6
CALL cmProcessPW
tst.l d7
beq.w .success ;Operation=Switch -> always successfull
cmp.w d0,d7
beq.w .success ;function did what i wanted!
lea NoAddTxt(pc),a0
cmp.w #cm_AddPW,d7
beq.s .schluss
lea NoRemTxt(pc),a0
; cmp.w #cm_RemovePW,d7 ;in the present version
; beq.s .schluss ;of the library this case
; lea NoRemAllTxt(pc),a0 ;can never occur!
.schluss:
bsr.w PrintText ;print result...
** Close CrM.library **
move.l _CrMBase(pc),d0
beq.s .CloseDOS
move.l d0,a1
CALLEXEC CloseLibrary
** Close dos.library **
.CloseDOS:
move.l _DOSBase(pc),a1
CALLEXEC CloseLibrary
.End: moveq #0,d0
rts
*-------
.checkadd:
cmp.b #" ",1(a0)
bne.s .switch ;no <Space>
moveq #cm_AddPW,d0
addq.l #1,a0
bsr.w SkipSpaces
bra.s .checkcont
*-------
.checkremove:
cmp.b #" ",1(a0)
bne.s .switch ;no <Space>
moveq #cm_RemovePW,d0
addq.l #1,a0
bsr.s SkipSpaces
cmp.b #"a",(a0)
bne.s .checkcont
cmp.b #"l",1(a0)
bne.w .checkcont
cmp.b #"l",2(a0)
bne.w .checkcont
tst.b 3(a0)
bne.w .checkcont
moveq #cm_RemoveAll,d0
bra.w .checkcont
*-------
.success:
lea AddedTxt(pc),a0
cmp.w #cm_AddPW,d0
beq.s .schluss
lea RemovedTxt(pc),a0
cmp.w #cm_RemovePW,d0
beq.s .schluss
lea RemAllTxt(pc),a0
bra.w .schluss
*-------
.nopw: lea NoPWTxt(pc),a0
bra.w .schluss
*-------
.nocrm:
lea NoCrMTxt(pc),a0
bra.w .schluss
.printinfo:
lea InfoTxt(pc),a0
bra.w .schluss
*------------
** Print some text to the CLI **
PrintText: ** a0:Text (0-terminated)
movem.l d0-d3/a0-a1/a6,-(sp)
move.l a0,d2
moveq #-1,d3
.count: addq.l #1,d3
tst.b (a0)+
bne.s .count
move.l OutHandle(pc),d1
CALLDOS Write
movem.l (sp)+,d0-d3/a0-a1/a6
rts
*----------
** Skip spaces in the String at a0 (set a0 to the first char after the spaces)
SkipSpaces: ** a0:String (0-terminated)
tst.b (a0)
beq.s .End
cmp.b #" ",(a0)+
beq.s SkipSpaces
subq.l #1,a0
.End: rts
***************************************
_DOSBase: dc.l 0
_CrMBase: dc.l 0
OutHandle: dc.l 0
CLIParas: dc.l 0,0
;PW: dc.l 0
DOSName: dc.b "dos.library",0
CrMName: CRMNAME
NoCrMTxt: dc.b "Could not open CrM.library v4+",10,0
InitTxt: dc.b 27,"[33;1mCrMPW",27,"[0;33m V1.0",27,"[32m -- ",27,"[0m",0
InfoTxt: dc.b "(c) 1993 Thomas Schwarz",10,10
dc.b "Usage: CrMPW <command> <pw>",10,10
dc.b " <pw>: password to add/remove",10
dc.b "<command>: a ·· Add PW to List",10
dc.b " r ·· Remove PW from List",10
dc.b " r all ·· Remove all PWs from List",10
dc.b " no command ·· Switch state",10,0
AddedTxt: dc.b "added pw to list",10,0
RemovedTxt: dc.b "removed pw from list",10,0
RemAllTxt: dc.b "removed all pws from list",10,0
NoAddTxt: dc.b "pw NOT added: already in list",10,0
NoRemTxt: dc.b "pw NOT removed: not in list",10,0
;NoRemAllTxt: dc.b "nothing to remove!",10,0
NoPWTxt: dc.b "NO pw given!",10,0